package com.zhuang.Iterator;

import java.util.List;

/**
 * @Classname StudentIteratorImpl
 * @Description 具体的迭代器类
 * @Date 2021/3/28 12:43
 * @Created by dell
 */

public class StudentIteratorImpl implements StudentIterator {

    private List<Student> list;
    private int position = 0;

    public StudentIteratorImpl(List<Student> list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        return position < list.size();
    }

    @Override
    public Student next() {
        Student currentStudent = list.get(position);
        position++;
        return currentStudent;
    }
}
